package ru.alt22.visor.php.unittests.run;

import org.eclipse.swt.widgets.Display;

import ru.alt22.visor.php.unittests.core.PHPTest;
import ru.alt22.visor.php.unittests.core.PHPTestListenter;
import ru.alt22.visor.php.unittests.core.PHPTestResult;

public class PHPTestRunner {

	private static PHPTestRunner instance = new PHPTestRunner();

	private PHPTestResult result;

	private PHPTestRunner() {
		result = new PHPTestResult();
	}

	public static PHPTestRunner instance() {
		return instance;
	}

	public void addListener(PHPTestListenter listener) {
		result.addListener(listener);
	}

	public void removeListener(PHPTestListenter listener) {
		result.removeListener(listener);
	}

	public void run(final PHPTest test) {
		new Thread(new Runnable() {
			public void run() {
				Display.getDefault().asyncExec(new Runnable() {
					public void run() {
						result.run(test, new DefaultPHPProxy());
					}
				});
			}
		}).start();
	}

}